.class public final Lnbisdk/rc;
.super Lnbisdk/nk;


# instance fields
.field private cB:Z

.field private in:Ljava/io/InputStream;

.field private ul:Ljava/lang/String;

.field private ya:Lnbisdk/qr;

.field private yb:Lnbisdk/rj;

.field private yc:I

.field private yd:I

.field private ye:[B

.field private yf:Lnbisdk/os;

.field private yg:I


# direct methods
.method public constructor <init>(Lnbisdk/hj;Lnbisdk/qr;)V
    .locals 3

    invoke-direct {p0}, Lnbisdk/nk;-><init>()V

    const/4 v0, 0x0

    iput-boolean v0, p0, Lnbisdk/rc;->cB:Z

    iput-object p2, p0, Lnbisdk/rc;->ya:Lnbisdk/qr;

    new-instance v0, Lnbisdk/fe;

    invoke-static {}, Lnbisdk/ix;->gN()Lnbisdk/ix;

    move-result-object v1

    invoke-virtual {v1}, Lnbisdk/ix;->gP()Lnbisdk/fq;

    move-result-object v1

    const/4 v2, 0x1

    invoke-direct {v0, v1, p1, v2}, Lnbisdk/fe;-><init>(Lnbisdk/fq;Lnbisdk/hj;Z)V

    iput-object v0, p0, Lnbisdk/rc;->yb:Lnbisdk/rj;

    return-void
.end method

.method private kN()V
    .locals 13

    const-wide/32 v11, 0x80000

    const/16 v10, 0x8

    const/4 v3, 0x0

    const/16 v0, 0x2800

    iget v1, p0, Lnbisdk/rc;->yc:I

    mul-int/lit16 v1, v1, 0x2800

    add-int/lit16 v1, v1, 0x2800

    iget v2, p0, Lnbisdk/rc;->yg:I

    if-le v1, v2, :cond_2

    iget v0, p0, Lnbisdk/rc;->yg:I

    iget v1, p0, Lnbisdk/rc;->yc:I

    mul-int/lit16 v1, v1, 0x2800

    sub-int/2addr v0, v1

    move v7, v0

    :goto_0
    :try_start_0
    new-instance v0, Ljava/io/ByteArrayOutputStream;

    invoke-direct {v0, v7}, Ljava/io/ByteArrayOutputStream;-><init>(I)V

    const/16 v1, 0x200

    new-array v1, v1, [B

    move v2, v3

    :goto_1
    if-gt v2, v7, :cond_0

    iget-object v3, p0, Lnbisdk/rc;->in:Ljava/io/InputStream;

    const/4 v4, 0x0

    array-length v5, v1

    invoke-virtual {v3, v1, v4, v5}, Ljava/io/InputStream;->read([BII)I

    move-result v3

    const/4 v4, -0x1

    if-eq v3, v4, :cond_0

    const/4 v4, 0x0

    invoke-virtual {v0, v1, v4, v3}, Ljava/io/ByteArrayOutputStream;->write([BII)V

    add-int/2addr v2, v3

    goto :goto_1

    :cond_0
    invoke-virtual {v0}, Ljava/io/ByteArrayOutputStream;->flush()V

    invoke-virtual {v0}, Ljava/io/ByteArrayOutputStream;->toByteArray()[B

    move-result-object v0

    iput-object v0, p0, Lnbisdk/rc;->ye:[B
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    :goto_2
    new-instance v0, Lnbisdk/os;

    iget-object v1, p0, Lnbisdk/rc;->yb:Lnbisdk/rj;

    iget-object v2, p0, Lnbisdk/rc;->ul:Ljava/lang/String;

    iget v3, p0, Lnbisdk/rc;->yc:I

    iget v4, p0, Lnbisdk/rc;->yd:I

    iget-object v5, p0, Lnbisdk/rc;->ye:[B

    iget v6, p0, Lnbisdk/rc;->yc:I

    mul-int/lit16 v6, v6, 0x2800

    iget-object v9, p0, Lnbisdk/rc;->ya:Lnbisdk/qr;

    move-object v8, p0

    invoke-direct/range {v0 .. v9}, Lnbisdk/os;-><init>(Lnbisdk/rj;Ljava/lang/String;II[BIILnbisdk/rc;Lnbisdk/qr;)V

    iput-object v0, p0, Lnbisdk/rc;->yf:Lnbisdk/os;

    sget-boolean v0, Lnbisdk/bk;->DEBUG:Z

    if-eqz v0, :cond_1

    new-instance v0, Ljava/lang/StringBuilder;

    invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V

    const-string v1, "Uploading Chunk "

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    iget v1, p0, Lnbisdk/rc;->yc:I

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-static {v0, v11, v12, v10}, Lnbisdk/pn;->a(Ljava/lang/String;JB)V

    :cond_1
    return-void

    :catch_0
    move-exception v0

    invoke-static {v0, v11, v12, v10}, Lnbisdk/pn;->a(Ljava/lang/Throwable;JB)V

    goto :goto_2

    :cond_2
    move v7, v0

    goto :goto_0
.end method


# virtual methods
.method final aJ(Ljava/lang/String;)V
    .locals 3

    const/4 v2, 0x0

    iput-object p1, p0, Lnbisdk/rc;->ul:Ljava/lang/String;

    iget v0, p0, Lnbisdk/rc;->yc:I

    add-int/lit8 v0, v0, 0x1

    iput v0, p0, Lnbisdk/rc;->yc:I

    iget v0, p0, Lnbisdk/rc;->yc:I

    iget v1, p0, Lnbisdk/rc;->yd:I

    if-ge v0, v1, :cond_0

    invoke-direct {p0}, Lnbisdk/rc;->kN()V

    iget-object v0, p0, Lnbisdk/rc;->yf:Lnbisdk/os;

    invoke-virtual {v0}, Lnbisdk/os;->start()V

    :goto_0
    return-void

    :cond_0
    iget-object v0, p0, Lnbisdk/rc;->ya:Lnbisdk/qr;

    iget v1, p0, Lnbisdk/rc;->yg:I

    invoke-interface {v0, p1, v1, p0}, Lnbisdk/qr;->uploadComplete(Ljava/lang/String;ILnbisdk/nk;)V

    iget-object v0, p0, Lnbisdk/rc;->ya:Lnbisdk/qr;

    invoke-interface {v0, p0}, Lnbisdk/qr;->onRequestComplete(Lcom/navbuilder/nb/b;)V

    iput-object v2, p0, Lnbisdk/rc;->ye:[B

    const/4 v0, 0x0

    iput-boolean v0, p0, Lnbisdk/rc;->cB:Z

    iput-object v2, p0, Lnbisdk/rc;->yf:Lnbisdk/os;

    goto :goto_0
.end method

.method public final cancelRequest()V
    .locals 1

    iget-boolean v0, p0, Lnbisdk/rc;->cB:Z

    if-eqz v0, :cond_0

    iget-object v0, p0, Lnbisdk/rc;->yf:Lnbisdk/os;

    if-eqz v0, :cond_0

    iget-object v0, p0, Lnbisdk/rc;->yf:Lnbisdk/os;

    invoke-virtual {v0}, Lnbisdk/os;->cancel()V

    :cond_0
    const/4 v0, 0x0

    iput-boolean v0, p0, Lnbisdk/rc;->cB:Z

    return-void
.end method

.method public final isRequestInProgress()Z
    .locals 1

    iget-boolean v0, p0, Lnbisdk/rc;->cB:Z

    return v0
.end method

.method public final startRequest()V
    .locals 5
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/IllegalStateException;
        }
    .end annotation

    const-wide/32 v3, 0x80000

    const/16 v2, 0x8

    iget-boolean v0, p0, Lnbisdk/rc;->cB:Z

    if-eqz v0, :cond_0

    new-instance v0, Ljava/lang/IllegalStateException;

    const-string v1, "Request is in progress"

    invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v0

    :cond_0
    invoke-static {}, Lnbisdk/ef;->getSize()I

    move-result v0

    iput v0, p0, Lnbisdk/rc;->yg:I

    iget v0, p0, Lnbisdk/rc;->yg:I

    if-nez v0, :cond_1

    iget-object v0, p0, Lnbisdk/rc;->ya:Lnbisdk/qr;

    new-instance v1, Lcom/navbuilder/nb/NBException;

    const/16 v2, 0x42

    const-string v3, "No QA Log Data"

    invoke-direct {v1, v2, v3}, Lcom/navbuilder/nb/NBException;-><init>(ILjava/lang/String;)V

    invoke-interface {v0, v1, p0}, Lnbisdk/qr;->onRequestError(Lcom/navbuilder/nb/NBException;Lcom/navbuilder/nb/b;)V

    :goto_0
    return-void

    :cond_1
    invoke-static {}, Lnbisdk/ef;->getInputStream()Ljava/io/InputStream;

    move-result-object v0

    iput-object v0, p0, Lnbisdk/rc;->in:Ljava/io/InputStream;

    const/4 v0, 0x0

    iput v0, p0, Lnbisdk/rc;->yc:I

    iget v0, p0, Lnbisdk/rc;->yg:I

    div-int/lit16 v0, v0, 0x2800

    iput v0, p0, Lnbisdk/rc;->yd:I

    iget v0, p0, Lnbisdk/rc;->yg:I

    rem-int/lit16 v0, v0, 0x2800

    if-eqz v0, :cond_2

    iget v0, p0, Lnbisdk/rc;->yd:I

    add-int/lit8 v0, v0, 0x1

    iput v0, p0, Lnbisdk/rc;->yd:I

    :cond_2
    sget-boolean v0, Lnbisdk/bk;->DEBUG:Z

    if-eqz v0, :cond_3

    const-string v0, "Uploading QA Log"

    invoke-static {v0, v3, v4, v2}, Lnbisdk/pn;->a(Ljava/lang/String;JB)V

    new-instance v0, Ljava/lang/StringBuilder;

    invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V

    const-string v1, "Total Size "

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    iget v1, p0, Lnbisdk/rc;->yg:I

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-static {v0, v3, v4, v2}, Lnbisdk/pn;->a(Ljava/lang/String;JB)V

    new-instance v0, Ljava/lang/StringBuilder;

    invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V

    const-string v1, "Total Chunks "

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    iget v1, p0, Lnbisdk/rc;->yd:I

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-static {v0, v3, v4, v2}, Lnbisdk/pn;->a(Ljava/lang/String;JB)V

    :cond_3
    const-string v0, ""

    iput-object v0, p0, Lnbisdk/rc;->ul:Ljava/lang/String;

    const/4 v0, 0x1

    iput-boolean v0, p0, Lnbisdk/rc;->cB:Z

    invoke-direct {p0}, Lnbisdk/rc;->kN()V

    iget-object v0, p0, Lnbisdk/rc;->ya:Lnbisdk/qr;

    invoke-interface {v0, p0}, Lnbisdk/qr;->onRequestStart(Lcom/navbuilder/nb/b;)V

    iget-object v0, p0, Lnbisdk/rc;->yf:Lnbisdk/os;

    invoke-virtual {v0}, Lnbisdk/os;->start()V

    goto :goto_0
.end method
